package com.fire.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.fire.definedAnnotation.Authorization;
import com.fire.service.TestService;
import com.fire.util.base.ResultBody;

import springfox.documentation.annotations.ApiIgnore;

@RestController
@RequestMapping("/testController")
@ApiIgnore
public class TestController {

	@Autowired
	private TestService testService;

	
	@RequestMapping("/test")
	public ResultBody test(HttpServletRequest request, HttpServletResponse response) {
		ResultBody result = null;
		try {
			result = testService.getUserName();
		} catch (Exception e) {
			ResultBody.goBack(500, "系统内部错误");
			e.printStackTrace();
			return result;
		}
		return result;
	}

	@Authorization
	@RequestMapping("/getToken")
	public ResultBody getToken(HttpServletRequest request, HttpServletResponse response) {
		ResultBody result = null;
		try {
			result = testService.getToken();
		} catch (Exception e) {
			ResultBody.goBack(500, "系统内部错误");
			e.printStackTrace();
			return result;
		}
		return result;
	}

}
